package com.yanqu.road.entity.activity.washe.config;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.LocalDateTimeHelper;
import com.yanqu.road.utils.date.DateHelper;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

@FieldTypeAnnotation(tableName = "t_n_washepvp_round")
public class WasheRoundConfig {

    @FieldTypeAnnotation(desc = "活动ID", select = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "赛季")
    private int seasonId;
    @FieldTypeAnnotation(desc = "轮次")
    private int round;
    @FieldTypeAnnotation(desc = "盘面机制id")
    private int sceneSkillId;
    @FieldTypeAnnotation(desc = "开战时间")
    private String warTimeStr;

    @FieldTypeAnnotation(desc = "备战时间")
    private int configPreparationTime;

    // 转时间戳方便用
    private long warTime;

    private long preparationTime;

    // ===============================

    public void init(int channelActivityTimeZone) {
        try {

            SimpleDateFormat format = new SimpleDateFormat("yyyy=MM=dd=HH=mm");
            format.setTimeZone(TimeZone.getDefault());

            Date beginShowTime = format.parse(warTimeStr);
            setWarTime(LocalDateTimeHelper.convertTimeZone(beginShowTime.getTime(), channelActivityTimeZone, false));

            setPreparationTime(getWarTime() - DateHelper.SECOND_MILLIONS * configPreparationTime);

        } catch (ParseException e) {
            e.printStackTrace();
            throw new RuntimeException();
        }
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getSeasonId() {
        return seasonId;
    }

    public void setSeasonId(int seasonId) {
        this.seasonId = seasonId;
    }

    public int getRound() {
        return round;
    }

    public void setRound(int round) {
        this.round = round;
    }

    public int getSceneSkillId() {
        return sceneSkillId;
    }

    public void setSceneSkillId(int sceneSkillId) {
        this.sceneSkillId = sceneSkillId;
    }

    public String getWarTimeStr() {
        return warTimeStr;
    }

    public void setWarTimeStr(String warTimeStr) {
        this.warTimeStr = warTimeStr;
    }

    public long getWarTime() {
        return warTime;
    }

    public void setWarTime(long warTime) {
        this.warTime = warTime;
    }

    public int getConfigPreparationTime() {
        return configPreparationTime;
    }

    public void setConfigPreparationTime(int configPreparationTime) {
        this.configPreparationTime = configPreparationTime;
    }

    public long getPreparationTime() {
        return preparationTime;
    }

    public void setPreparationTime(long preparationTime) {
        this.preparationTime = preparationTime;
    }
}
